#include "junix.h"
using namespace std;

int main(int argc, char **argv)
{
	vector<int> vi(30);
	generate(vi.begin(),vi.end(),
			boost::bind(modulus<int>(), boost::bind(rand), 30));

	ostream_iterator<int> oit(cout," ");
	copy(vi.begin(),vi.end(), oit);
	cout<<endl;

	nth_element(vi.begin(),vi.begin()+8, vi.end()); 
	copy(vi.begin(),vi.end(),oit);
	cout<<endl;

	nth_element(vi.begin(), vi.begin()+15,vi.end(),
			boost::bind(greater<int>(),
				boost::bind(modulus<int>(),_1,20),
				boost::bind(modulus<int>(),_1,9)));

	copy(vi.begin(),vi.end(),oit);
	cout<<endl;
}
